今天閱讀「適用於 Android 開發人員的 Jetpack Compose」第二章「版面配置、主題設定和動畫」的「設定文字樣式」
bodyLarge = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Normal,
fontSize = 24.sp,
lineHeight = 16.sp,
letterSpacing = 0.15.sp
)
Text(
text = message,
style = MaterialTheme.你設定的style.bodyLarge.copy(color = Red)
)
Text(
text = message,
maxLines = 10,
overflow = TextOverflow.Ellipsis,
onTextLayout = {
if (it.hasVisualOverflow) {
// 顯示更多按鈕
}
}
)
val provider = GoogleFont.Provider(...)
//設定自定義字體和備用字體
val fontFamily = FontFamily(
Font(googleFont = LobsterTwo,
fontProvider = provider)
)
val chatTypography = Typography(
displayLarge = TextStyle(
fontFamily = fontFamily
)
)